/*
* 公司：Leita Tech
* 版权信息：雷塔所有
* 任务：
* 描述：
* 作者：李大平
* 日期：2020/06/04
*
*/

#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QTextCodec>
#include <QDebug>
#include "model/LTFundModel.h"
#include "ui/LTJsObject.h"

int main(int argc, char *argv[])
{
    QGuiApplication::setApplicationName("LeitaFund");
    QGuiApplication::setOrganizationName("LeitaTech");
    //QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    QGuiApplication::setAttribute(Qt::AA_DisableHighDpiScaling);
    QGuiApplication::setAttribute(Qt::AA_Use96Dpi);

    QGuiApplication app(argc, argv);

    QTextCodec *codec = QTextCodec::codecForName("UTF-8");
    QTextCodec::setCodecForLocale(codec);

    QQmlApplicationEngine engine;
    QQmlContext *context = engine.rootContext();

    LTFundModel fund_model(context);
    context->setContextProperty(QStringLiteral("fundModel"), QVariant::fromValue(&fund_model));
    LTJsObject *js_object = LTJsObject::getInstance();
    context->setContextProperty(QStringLiteral("jsObject"), QVariant::fromValue(js_object));

    engine.load(QUrl("qrc:/qml/main.qml"));
    if (engine.rootObjects().isEmpty())
        return -1;

    if(!js_object->init())
    {
        qDebug() << "js_object->init() failed.";
    }
    fund_model.update();

    return app.exec();
}
